<!DOCTYPE html>

<html lang="en">



<head>

    <meta charset="UTF-8">

    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">

    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>一朵 - 我的优惠券</title>

    <!-- swiper-2.7css -->

    <link rel="stylesheet" href="__STATIC__/index/js/swiper/idangerous.swiper.css">

    <!-- swiper-2.7js -->

    <script src="__STATIC__/index/js/swiper/idangerous.swiper.min.js"></script>

    <!-- jquery-3.2.1引用 -->

    <script src="__STATIC__/index/js/global/jquery-3.2.1.min.js"></script>

    <!-- 阿里巴巴矢量图库 -->

    <link rel="stylesheet" href="http://at.alicdn.com/t/font_561814_yo33l6f1qxhl4n29.css">

    <!-- 公共头部 脚部 -->

    <link rel="stylesheet" href="__STATIC__/index/css/global/global.css">

    <!-- 超过1200屏幕 -->

    <link rel="stylesheet" media="screen and (min-width: 1200px)" href="__STATIC__/index/css/discount/discount1200.css" />

    <!-- 1080-1200 -->

    <link rel="stylesheet" media="screen  and (min-width: 1080px) and (max-width: 1199px) " href="__STATIC__/index/css/discount/discount1080.css"
    />

    <!-- 960-1080 -->

    <link rel="stylesheet" media="screen  and (min-width: 960px) and (max-width: 1079px) " href="__STATIC__/index/css/discount/discount960.css"
    />

    <!-- 768-959 -->

    <link rel="stylesheet" media="screen  and (min-width: 768px) and (max-width: 959px) " href="__STATIC__/index/css/discount/discount768.css"
    />

    <!-- 568-767 -->

    <link rel="stylesheet" media="screen  and (min-width: 568px) and (max-width: 767px) " href="__STATIC__/index/css/discount/discount568.css"
    />

    <!-- 375-567 -->

    <link rel="stylesheet" media="screen  and (min-width: 375px) and (max-width: 567px) " href="__STATIC__/index/css/discount/discount375.css"
    />

    <!-- 小于375-->

    <link rel="stylesheet" media="screen  and (max-width: 374px) " href="__STATIC__/index/css/discount/discount320.css" />

    <!--一引入layer-->

    <script src="__STATIC__/layer/layer.js"></script>

</head>



<body>

    <div class="M">

        <div class="m-header">

            <div>

                <span onclick="go_back();">

                    <span class="iconfont icon-xiangzuo"></span>

                    返回

                </span>

                <span>优惠券</span>

                <span>

                    {if condition="!empty($realname)"}

                    <a href="{:url('User/index')}" class="my">

                        {$realname}

                    </a>

                    {else /}

                    <a href="{:url('Login/loginin')}">登录</a>

                    <a href="{:url('Login/register')}">注册</a>

                    {/if}

                    <a href="{:url('MyCart/my_cart')}" class="car">

                        <span class="iconfont icon-gouwuche"></span>

                        <span>{$cart_num}</span>

                    </a>

                </span>

            </div>



        </div>

        <div class="m-headline">

            <a href="{:url('User/my_coupon')}?type=1" {if condition="$type eq 1" } class="m-headline-zhong" {/if}>

                未使用

            </a>

            <a href="{:url('User/my_coupon')}?type=2" {if condition="$type eq 2" } class="m-headline-zhong" {/if}>

                未领取

            </a>

            <a href="{:url('User/my_coupon')}?type=3" {if condition="$type eq 3" } class="m-headline-zhong" {/if}>

                已使用

            </a>

            <a href="{:url('User/my_coupon')}?type=4" {if condition="$type eq 4" } class="m-headline-zhong" {/if}>

                已过期

            </a>

        </div>
        {if condition="!empty($list)"}
        <div class="m-list">

            <!-- 循环开始 -->

            {foreach name="list" item="v"}

            <div class="">

                <div>

                    <img src="{$v.img}" alt="">

                </div>

                <div>

                    <div>

                        <p>

                            <span>￥</span>
                            {if $v.type eq 2}
                            <span>{$v.value}</span>
                            {else /}
                            <span>{$v.reduce}</span>
                            {/if}
                        </p>

                    </div>

                    <div>
                        {if $v.type eq 2}
                        <p>代金券（{$v.title}）</p>
                        {else /}
                        <p>满{$v.morethan}减{$v.reduce} {if condition="!empty($v.title)"} （{$v.title}） {/if}

                        </p>
                        {/if}

                        <p>{$v.use_start_time|date="Y.m.d",###}-{$v.use_end_time|date="Y.m.d",###}</p>

                    </div>

                    <div>

                        {if condition="$type eq 1"} {if condition="$v.use_start_time lt $nowtime"}

                        <a href="{:url('GoodsList/goods_list')}" class="m-shiyong">使用</a>

                        {else /}

                        <a href="javascript:;" class="m-guoqi">不可用</a>

                        {/if} {elseif condition="$type eq 2"}

                        <a href="javascript:;" class="m-lingqu" onclick="receive_coupon({$v.id})">领取</a>

                        {elseif condition="$type eq 3"}

                        <a href="javascript:;" class="m-yishiyong">已使用</a>

                        {else /}

                        <a href="javascript:;" class="m-guoqi">已过期</a>

                        {/if}

                    </div>

                </div>

            </div>

            {/foreach}

            <!-- 循环结束 -->

        </div>
        {/if}
        {if condition="empty($list)"}
        <div class="m-kong">
            <img src="__STATIC__/index/img/coupon.png" alt="">
            <p>没有优惠券了</p>
            <p>······</p>
        </div>
        {/if}


    </div>

    <!------------------------ PC ------------------------>



    <div class="PC">

        <!-- 公共头部 -->

        {include file="public/p_header" /}

        <!-- 公共头部结束 -->

        <div class="pc-content">

            {include file="public/p_user" /}



            <div class="PC_right">

                {include file="public/p_user_info" /}

                <div class="pc-tihuan">



                    <div class="pc-select">



                        <div>

                            <span>

                                <a href="{:url('User/my_coupon')}?type=1" {if condition="$type eq 1" } class="pc-liang" {/if}>未使用</a>

                            </span>

                            <span>

                                <a href="{:url('User/my_coupon')}?type=2" {if condition="$type eq 2" } class="pc-liang" {/if}>未领取</a>

                            </span>

                            <span>

                                <a href="{:url('User/my_coupon')}?type=3" {if condition="$type eq 3" } class="pc-liang" {/if}>已使用</a>

                            </span>

                            <span>

                                <a href="{:url('User/my_coupon')}?type=4" {if condition="$type eq 4" } class="pc-liang" {/if}>已过期</a>

                            </span>

                        </div>

                    </div>
                    {if condition="!empty($list)"}
                    <div class="pc-for">

                        <!-- 循环开始 -->

                        {foreach name="list" item="v"}

                        <span>

                            <span style="background: url('{$v.img}') no-repeat 100%;">

                                <span>￥</span>
                                {if $v.type eq 2}
                                <span>{$v.value}</span>
                                {else /}
                                <span>{$v.reduce}</span>
                                {/if}
                            </span>

                            <span>
                                {if $v.type eq 2}
                                <p>代金券（{$v.title}）</p>
                                {else /}
                                <p>满{$v.morethan}减{$v.reduce} {if condition="!empty($v.title)"} （{$v.title}） {/if}

                                </p>
                                {/if}

                                <p>{$v.use_start_time|date="Y.m.d",###}-{$v.use_end_time|date="Y.m.d",###}</p>

                            </span>

                            <span>

                                {if condition="$type eq 1"} {if condition="$v.use_start_time lt $nowtime"}

                                <a href="{:url('GoodsList/goods_list')}" class="pc-shiyong">使用</a>

                                {else /}

                                <a href="javascript:;" class="pc-guoqi">不可用</a>

                                {/if} {elseif condition="$type eq 2" /}

                                <a href="javascript:;" class="pc-lingq" onclick="receive_coupon({$v.id});">领取</a>

                                {elseif condition="$type eq 3"}

                                <a href="javascript:;" class="pc-yishiyong">已使用</a>

                                {else /}

                                <a href="javascript:;" class="pc-guoqi">已过期</a>

                                {/if}

                            </span>

                        </span>

                        {/foreach}

                        <!-- 循环结束 -->

                    </div>
                    {/if}
                    {if condition="empty($list)"}
                    <div class="pc-kong">
                        <img src="__STATIC__/index/img/coupon.png" alt="">
                        <p>没有优惠券了</p>
                        <p>······</p>
                    </div>
                    {/if}
                </div>

            </div>

        </div>

        <!-- 公共脚部  -->

        {include file="public/p_footer" /}

        <!-- 公共脚部 结束 -->



    </div>

    <script>
        /**

                 * 返回上一页

                 */

        function go_back() {

            window.history.back(); //返回上一页

        }

        /**

         * 领取优惠券

         * @param id    优惠券id

         */

        function receive_coupon(id) {

            $.post("{:url('User/receive_coupon')}",

                {
                    id: id
                },

                function (data) {

                    if (data.code == 1) {

                        layer.msg('领取成功', {
                            icon: 1,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {

                            layer.close(index);

                            location.reload();

                        });

                        return false;

                    } else {

                        layer.msg(data.msg, {
                            icon: 2,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {

                            layer.close(index);

                        });

                        return false;

                    }

                }

            );

        }



        /**

         * 完善会员信息

         */

        function edit_member_info() {

            window.location.href = "{:url('User/my_center')}";

        }
    </script>

</body>



</html>